import { useEffect } from 'react';
import { useNavigate } from 'react-router-dom';
/**
 * 判断登录状态的函数组件
 * */
const Auth = ({ children }) => {
    const navigate = useNavigate();
    const { token } = JSON.parse(localStorage.getItem('adminLoginInfo') || '{}');
    useEffect(() => {
        if (!token) {
            // 重定向到登录页面
            navigate('/login', { replace: true });
        }
    }, [token,navigate]);
    return children
}
export default Auth;